<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <common-head></common-head>
  </div>
</body>
<script src="./vue.js"></script>
<script>
  Vue.component('CommonHead',{
    template: `
      <div>
        <h1 ref='h1'>我是头部组件</h1>
        <button @click='addArr'>增加li</button>
        <ul ref='oul'>
          <li v-for='item in arr' :key='item'>
            {{ item }}
          </li>
        </ul>
      </div>      
    `,
    data(){
      return{
        arr: [1,2]
      }
    },
    methods: {
      addArr(){
        this.arr.push(this.arr.length+1)
      }
    },
    beforeCreate() {
      console.log('beforeCreate触发');
    },
    created() {
      console.log('created 触发');
    },
    beforeMount() {
      console.log('beforeMount触发');
    },
    mounted() {
      console.log('mounted触发');
    },
    beforeUpdate() {
      console.log('beforeUpdate触发');
    },
    updated() {
      console.log('updtaed触发');
      console.log(this.$refs.oul.children);
      this.$refs.oul.lastChild.style.background='#abcdef';
    },
    beforeDestroy() {
      console.log('beforeDstroy触发');
    },
    destroyed() {
      console.log('destroyed触发');
    },
  })
  const vm = new Vue({
    el: '#app'
  })
</script>
</html>